<%--
  Created by IntelliJ IDEA.
  User: empty
  Date: 2025/5/27
  Time: 12:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <title>浏览公告</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Arial', sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            padding: 20px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
            padding: 15px 0;
            border-bottom: 1px solid #dee2e6;
        }

        .header h1 {
            color: #343a40;
            font-size: 28px;
        }

        #logout button {
            background-color: #6c757d;
            color: white;
            border: none;
            padding: 10px 15px;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
            font-size: 14px;
        }

        #logout button:hover {
            background-color: #5a6268;
        }

        #app {
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
            padding: 30px;
            width: 100%;
            max-width: 800px;
            margin: 0 auto;
            transition: transform 0.3s ease;
        }

        #app:hover {
            transform: translateY(-2px);
        }

        #app h2 {
            color: #343a40;
            font-size: 24px;
            margin-bottom: 25px;
            border-left: 4px solid #4a89dc;
            padding-left: 10px;
        }

        .announcement-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
        }

        .announcement-card {
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
            padding: 20px;
            border-left: 4px solid #4a89dc;
            transition: transform 0.3s ease;
        }

        .announcement-card:hover {
            transform: translateY(-2px);
        }

        .announcement-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .announcement-id {
            font-size: 14px;
            color: #6c757d;
        }

        .announcement-title {
            font-size: 18px;
            font-weight: 600;
            color: #343a40;
        }

        .announcement-content {
            font-size: 15px;
            color: #495057;
            line-height: 1.6;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
        }

        .no-data {
            text-align: center;
            padding: 50px;
            color: #6c757d;
            font-size: 16px;
        }

        .message {
            margin: 20px auto 0;
            padding: 12px;
            border-radius: 5px;
            text-align: center;
            font-size: 14px;
            max-width: 800px;
            width: 100%;
        }

        .message:empty {
            display: none;
        }

        .message:not(:empty) {
            animation: fadeIn 0.5s ease;
        }

        .message.error {
            background-color: #f8d7da;
            color: #721c24;
        }

        .message.success {
            background-color: #d4edda;
            color: #155724;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-10px); }
            to { opacity: 1; transform: translateY(0); }
        }
    </style>
</head>
<body>
<div class="header">
    <h1>社区公告管理系统</h1>
    <div id="logout">
        <form action="user-community" name="action" method="post">
            <input type="hidden" name="action" value="returnAdmin">
            <button type="submit">居民首页</button>
        </form>
    </div>
</div>

<div id="app">
    <h2>社区公告</h2>

    <div class="announcement-container">
        <c:if test="${not empty announcementsList}">
            <c:forEach var="item" items="${announcementsList}">
                <div class="announcement-card">
                    <div class="announcement-header">
                        <div class="announcement-title">${item.title}</div>
                        <div class="announcement-id">公告ID: ${item.announcement_id}</div>
                    </div>
                    <div class="announcement-content">${item.content}</div>
                </div>
            </c:forEach>
        </c:if>
        <c:if test="${empty announcementsList}">
            <div class="no-data">
                <p>暂无公告信息</p>
            </div>
        </c:if>
    </div>
</div>

<div class="message ${message ? (message.startsWith('成功') ? 'success' : 'error') : ''}">${message}</div>
</body>
</html>
